<!-- zdy-tabbar.vue -->
<template>
	<view class="tabbar-container">
		<block>
			<view class="tabbar-it" v-for="(it, index) in tabbarList" :class="[it.centerit ? 'center-it' : '']"
				:key="index" @click="changeit(it)">
				<view class="it-top">
					<image :src="currentit == it.id ? it.selectIcon : it.icon"></image>
				</view>
				<view class="it-bottom" :class="[currentit == it.id ? 'it-active' : '']">
					<text>{{ it.text }}</text>
				</view>
			</view>
		</block>
	</view>
</template>

<script>
	export default {
		props: {
			currentPage: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				currentit: 0,
				tabbarList: [{
						id: 0,
						path: '/pages/index/index',
						icon: '/static/首页未点击.png',
						selectIcon: '/static/首页点击.png',
						text: '首页',
						centerit: false
					},
					{
						id: 1,
						path: '/pages/AISearchpage/AISearchpage',
						icon: '/static/AI搜卷未点击.png',
						selectIcon: '/static/AI搜卷点击.png',
						text: 'AI搜卷',
						centerit: false
					},
					{
						id: 2,
						path: '/pages/BlindboxPage/BlindboxPage',
						icon: '/static/开盲盒未点击.png',
						selectIcon: '/static/开盲盒点击.png',
						text: '开盲盒',
						centerit: true
					},
					{
						id: 3,
						path: '/pages/CirclePage/CirclePage',
						icon: '/static/七百圈未点击.png',
						selectIcon: '/static/七百圈点击.png',
						text: '七百圈',
						centerit: false
					},
					{
						id: 4,
						path: '/pages/home/home',
						icon: '/static/我的未点击.png',
						selectIcon: '/static/我的点击.png',
						text: '我的',
						centerit: false
					}
				]
			};
		},
		mounted() {
			this.currentit = this.currentPage;
			uni.hideTabBar();
			console.log("使用")
		},
		methods: {
			changeit(it) {
				let _this = this;
				uni.switchTab({
					url: it.path,
					success: () => {

					},
					fail: (err) => {
						console.log("跳转", err)
					}
				});
			}
		}
	};
</script>

<style scoped>
	view {
		padding: 0;
		margin: 0;
		box-sizing: border-box;
	}

	.tabbar-container {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 110rpx;
		box-shadow: 0 0 5px #999;
		display: flex;
		align-items: center;
		padding: 5rpx 0;
		color: #999999;
		background-color: white;
	}

	.tabbar-container .tabbar-it {
		width: 20%;
		height: 100rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		text-align: center;
	}

	.tabbar-container .it-active {
		color: #000000;
	}

	.tabbar-container .center-it {
		display: block;
		position: relative;
	}

	.tabbar-container .tabbar-it .it-top {
		width: 70rpx;
		height: 70rpx;
		padding: 10rpx;
	}

	.tabbar-container .center-it .it-top {
		width: 100rpx;
		height: 115rpx;
		position: absolute;
		top: -60rpx;
		left: calc(50% - 50rpx);
		border-radius: 50%;
		background-color: #ffffff;
		padding-bottom: 36rpx;
	}

	.tabbar-container .tabbar-it .it-top image {
		width: 100%;
		height: 100%;
	}

	.tabbar-container .tabbar-it .it-bottom {
		font-size: 28rpx;
		width: 100%;
	}

	.tabbar-container .center-it .it-bottom {
		position: absolute;
		bottom: 40rpx;
	}
</style>
